﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using iTextSharp;
using iTextSharp.text;
using iTextSharp.text.pdf;

namespace Gollie.Pdf
{
	public class PdfRow : Collection<PdfCell>
	{
		internal PdfRow(int colCount)
			: this(null, colCount)
		{
		}

		internal PdfRow(PdfCellProperties properties, int colCount)
		{
			for (int i = 0; i < colCount; i++)
				this.Add(new PdfCell(properties));
		}

		internal PdfRow(PdfCellProperties properties, string[] texts, int colCount)
		{
			int textIndex = 0;

			for (int i = 0; i < colCount; i++)
			{
				PdfCell cell = new PdfCell(properties);
				cell.Text = texts[textIndex++];

				this.Add(cell);

				if (properties.Colspan > 1)
					i += (properties.Colspan - 1);
			}
		}

		internal PdfRow(PdfCellProperties[] properties, string[] texts, int colCount)
		{
			for (int i = 0; i < colCount; i++)
			{
				PdfCell cell = new PdfCell(properties[i]);
				cell.Text = texts[i];

				this.Add(cell);
			}
		}
	}
}
